# 方法1
a = "awfa 32 fa"
b = ""
for i in a:
    if i.isspace():
        i = '%'
    b = b + i

print(b)

# 方法2
def func(s):
    res = ""
    for i in s:
        if i != " ":
            res += i

        else:
            res += "%"
    return res

print(func("aaf sfa  afdf"))









